package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.dto.CompanyDto;
import com.ant.storage.handler.AntException;
import com.ant.storage.service.ICompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2025-10-23
 */
@Api(tags = "企业信息接口")
@RestController
@RequestMapping("/companys")
public class CompanyController {

    @Autowired
    ICompanyService companysService;

    @ApiOperation(value = "获取所有企业信息列表")
    @GetMapping("/list")
    public ResultVo list(){
        return ResultVo.success("ok",companysService.list());
    }

    @ApiOperation(value = "保存企业信息")
    @PostMapping("/save")
    public ResultVo save(@RequestBody CompanyDto dto)
    {
        return ResultVo.success("添加成功",companysService.saveCompany(dto));
    }

    @ApiOperation(value = "通过企业id获取企业的披露表一信息")
    @GetMapping("/findCompanyoOrganicById")
    public ResultVo findCompanyoOrganicById(Integer id){
        if(id==null){
            throw new AntException("请输入id");
        }
        return ResultVo.success("ok",companysService.findCompanyOrganicById(id));
    }


    @ApiOperation(value = "通过企业id获取企业的披露表二信息")
    @GetMapping("/findCompanyMaterialById")
    public ResultVo findCompanyMaterialById(Integer id){
        if(id==null){
            throw new AntException("请输入id");
        }
        return ResultVo.success("ok",companysService.findCompanyMaterialById(id));
    }
}
